<template>
  <div class="body">
    <div class="box">
      <div class="drawing">
        <div><img src="../../assets/login/Login map.png" /></div>
      </div>
      <div class="input-box">
        <div style="margin-top: 54px"><img src="../../assets/login/logo.png" /></div>
        <div style="font-size: 24px; font-weight: 600; margin-top: 34px">江苏一道云科技发展有限公司</div>
        <div style="margin-top: 55px">
          <a-form :form="form"  :wrapper-col="{ span: 14, offset: 5}" @submit="handleSubmit" style="text-align: center;">
            <a-form-item>
              <a-input size="large" v-decorator="['account', { rules: [{ required: true, message: '请输入账用户名' }], initialValue: 'admin' }]" placeholder="请输入账用户名">
                <a-icon type="user" slot="prefix" style="color:rgba(0,0,0,.25)"/>
              </a-input>
            </a-form-item>
            <a-form-item style="margin-top:40px">
              <a-input size="large" v-decorator="['pwd', { rules: [{ required: true, message: '请输入密码' }], initialValue: '123456' }]"  placeholder="请输入密码">
                <a-icon type="lock" slot="prefix" style="color:rgba(0,0,0,.25)"/>
              </a-input>
            </a-form-item>
            <a-form-item  style="margin-top:57px">
              <a-button type="primary" size="large" html-type="submit" block> 登录 </a-button>
            </a-form-item>
          </a-form>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: this.$form.createForm(this, { name: 'coordinated' }),
      message: 'hello world',
    };
  },
  created() {},
  methods: {
    handleSubmit(e) {
      var that = this;
      e.preventDefault();
      this.form.validateFields((err, values) => {
        if (!err) {
          //   console.log('Received values of form: ', values);
          that.axios.post('/admin/login', values).then((req) => {
            if (req.data.code == 200) {
              console.log(req.data.admin);
              that.$message.success('登录成功');
              that.store.admin.token = req.data.admin.token;
              that.store.admin.id = req.data.admin.id;
              that.store.admin.isLogin = true;
              that.$router.push({
                name: 'dashboard',
                params: {
                  name: '----', //测试参数传递
                },
              });
            } else {
              that.$message.error(req.data.error);
            }
          });
        }
      });
    },
  },
};
</script>

<style >
.body {
  width: 100%;
  height: 745px;
  background-image: url('../../assets/login/Login background.jpg');
  display: flex;
  align-items: center;
  justify-content: center;
}
.box {
  width: 1150px;
  height: 580px;
  background-color: #ffffff;
  border-radius: 20px;
  box-shadow: 3px 0 10px 0 #cbced5;
  display: flex;
  overflow: hidden;
}
.drawing {
  width: 630px;
  height: 580px;
  background-color: #f4f6fb;
}
.drawing div {
  margin: 99px 0 0 48px;
}
.input-box {
  width: 520px;
  height: 580px;
  background-color: #ffffff;
  text-align: center;
}
</style>



